package com.thf.service.impl;

import com.thf.dao.impl.WordsDaoImpl;
import com.thf.model.WordsModels;
import com.thf.service.WordsService;
import com.thf.util.FileDataUtil;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class WordsServiceImpl implements WordsService {

    WordsDaoImpl wdi =new WordsDaoImpl();
    @Override
    public String[] getWordsData(String inPath, String outPath, String pathName) {
        String filePath = wdi.createFileData(inPath,outPath,pathName);
        String[] fileData = null ;
        try {
            fileData = FileDataUtil.getFileData(filePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return fileData ;
    }

    @Override
    public List<WordsModels> setWordsData() {
        List<WordsModels> list = new ArrayList<>() ;
        String[] wordsData = getWordsData("D:/test/wordsData.txt", "D:\\huarui03\\web\\WEB-INF\\note", "wordsData.txt");
        for (int i = 0; i <wordsData.length; i++) {
            WordsModels wordsModels = new WordsModels(wordsData[i]);
            list.add(wordsModels);
        }
        return list ;
    }
}
